home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8033 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  52 lines

  1. Path: robertk.accessone.com!user
  2. From: robertk@accessone.com (robertk)
  3. Newsgroups: comp.lang.c
  4. Subject: very simple newbie question with correction
  5. Date: 1 Mar 1996 07:02:32 GMT
  6. Organization: Kingdom
  7. Message-ID: <robertk-0103960001470001@robertk.accessone.com>
  8. NNTP-Posting-Host: robertk.accessone.com
  9.  
  10. sorry... reposting this with "s\n" in the 2nd example instead of my
  11. original "%s/n" .... how come.....when i do this .... 
  12.          
  13.             
  14.            #include <stdio.h>
  15.             main()
  16.             {
  17.               char s[10];
  18.               scanf("%s",s);
  19.               printf("%s",s);
  20.              }
  21.  
  22.             when i run this and input:
  23.  
  24.                   robert <enter> --->soon as i hit the enter key i am 
  25.                                     thrown back to the ide-upon returning to 
  26.                                     the screen i see 
  27.                   robert
  28.                   robert 
  29.  
  30.                BUT...........
  31.  
  32.              #include <stdio.h>
  33.              main()
  34.              {
  35.               char s[10];
  36.               scanf("%s\n",s);
  37.               printf("%s",s);
  38.              }
  39.  
  40.             when i run this and input:
  41.  
  42.                   robert <enter> --->when i hit the enter key the cursor 
  43.                                      drops down a line and sits ther flashing
  44.                                      waiting for me to enter another character
  45.                                      like x before it will throw me back to the
  46.                                      ide. upon returning to the screen i see
  47.                   robert
  48.                   x
  49.                   robert
  50.  
  51.                i thought scanf() ignored whitespace?
  52.